package pl.edu.agh.mguesser.game;

import pl.edu.agh.mguesser.game.listener.*;

/**
 * @author keiran
 */
public interface GameFlow extends GameStartedSource, NewRoundSource, 
                                  UserChangedSource, StopRequestSource, 
                                  TimeTickingSource, SongRevealedSource,
                                  AnswerRequiredSource, ScoreChangedSource, 
                                  GameDoneSource {
    
    void setGameSettings(GameSettings settings);
    
    void play() throws GameFlowException;
    
    void gameStarting();
    void donePlaying();
    
//    public void playOld() {
//        for(int i = 0; i < rounds; i++) {
//            for(User user : users) {
//                // play song
//                // wait for stop
//                // get answer
//                // judge answer
//                // update score
//                // next song
//            }
//        }
//    }
//    
//    public void playTheFirstTheBetter() {
//        for(int i = 0; i < rounds; i++) {
//            // play song
//            // wait for stop
//            // get answer from the user who stopped
//            // judge answer
//            // update the user's score
//            // next song
//        }
//    }
//    
//    public void playCorrectGuesserChoosesNextOne() {
//        Map<User, Integer> correctAnswers = new HashMap<>();
//        
//        User gotThree = null;
//        while((gotThree = threeCorrectAnswers(correctAnswers)) == null) {
//            // play song
//            // wait for stop
//            // get answer from the user who stopped
//            // judge answer
//            // update the user's score
//            // next song
//        }
//        
//        // the user with three correct answer is the first user chooser
//        User choosingUser = gotThree;
//        
//        for(int i = 0; i < rounds; i++) {
//            User currentUser = null;
//            // let the choosing user choose the current user
//            
//            // play song for current user
//            // wait for him to stop
//            // get answer from him
//            
//            boolean correct = false;
//            // judge answer
//            // update the user's score (x2 if choosing user equals current user)
//            
//            if(correct) {
//                // change the choosing user
//                choosingUser = currentUser;
//            } else {
//                // the last one still chooses the next one
//            }
//            
//            // next song
//        }
//    }
//    
//    private User threeCorrectAnswers(Map<User, Integer> correctAnswers) {
//        for(Map.Entry<User, Integer> entry : correctAnswers.entrySet()) {
//            if(entry.getValue() > 2) {
//                return entry.getKey();
//            }
//        }
//        
//        return null;
//    }

}
